package cc.cary.warehouse.common;

import org.springframework.lang.Nullable;

/**
 * 数据库定义的常量
 *
 * @author Cary
 * @date 2023/1/16
 */
public class Const {
    // 用户状态
    public enum UserStatusEnum implements DBEnum {
        ENABLED("正常"),
        DISABLED("禁用");
        private String mean = "";

        UserStatusEnum(String mean) {
            this.mean = mean;
        }

        @Nullable
        public static UserStatusEnum of(String name) {
            return DBEnum.of(UserStatusEnum.values(), name);
        }

        @Override
        public String getMean() {
            return this.mean;
        }
    }

    // 用户性别
    public enum UserGenderEnum implements DBEnum {
        UNDEFINED("未定义", 0),
        MALE("男性", 1),
        WOMAN("女性", 2);
        private String mean = "";
        private Integer code = 0;

        UserGenderEnum(String mean, Integer code) {
            this.mean = mean;
            this.code = code;
        }

        @Nullable
        public static UserGenderEnum of(String name) {
            return DBEnum.of(UserGenderEnum.values(), name);
        }

        @Nullable
        public static UserGenderEnum of(Integer code) {
            return (UserGenderEnum) DBEnum.of(UserGenderEnum.values(), code);
        }

        @Override
        public String getMean() {
            return this.mean;
        }

        @Override
        public Integer getCode() {
            return this.code;
        }
    }

    // 课程分类等级
    public enum ProjectCategoryLevelEnum implements DBEnum {
        MASTER(1),
        SUB(2);
        private Integer code = 0;

        ProjectCategoryLevelEnum(Integer code) {
            this.code = code;
        }

        @Nullable
        public static ProjectCategoryLevelEnum of(String name) {
            return DBEnum.of(ProjectCategoryLevelEnum.values(), name);
        }

        @Override
        public Integer getCode() {
            return this.code;
        }
    }
}
